import yaml, os

CONFIG_PATH = '../../../config/config.yml'

def load_config(config_path=CONFIG_PATH):
    # Load config file
    os.chdir(os.path.dirname(__file__))
    with open(config_path, 'r') as file:
        config = yaml.load(file, Loader=yaml.FullLoader)
        return config

def save_config(config: dict, config_path=CONFIG_PATH):
    # Save config file
    os.chdir(os.path.dirname(__file__))
    with open(config_path, 'w') as file:
        yaml.dump(config, file)

def get_config_value(config: dict, key: str):
    # Get value from config file
    return config[key]

def set_config_value(config: dict, key: str, value):
    # Set value in config file
    config[key] = value

def update_config(config: dict, key: str, value):
    # Update config file
    set_config_value(config, key, value)
    save_config(config)

def set_path(config: dict, key: str, path: str):
    # Set path in config file
    config[key] = path
    save_config(config)
    